﻿/*
==================================================================
    注意：此文件为Auto代码，不可手动修改【状态标准明细】
==================================================================
*/

namespace Services
{
    /// <summary>
    /// Auto状态标准明细
    /// </summary>
    public abstract class AutoStandStatusDetailMapping : BaseMapping<StandStatusDetail, StandStatusDetailModel, StandStatusDetailFilterModel>
    {
        public AutoStandStatusDetailMapping(ICurrentUser currentUser)
            : base(currentUser) { }

        #region 读数据
        /// <summary>
        /// 读数据，从Entity对象转成Model对象
        /// </summary>
        /// <param name="entity">Entity对象</param>
        /// <returns></returns>
        public override StandStatusDetailModel Entity2Model(StandStatusDetail entity)
        {
            StandStatusDetailModel model = new StandStatusDetailModel();

            model.StandStatusDetailID = entity.StandStatusDetailID;
            model.GroupInfoID = entity.GroupInfoID;
            model.StandStatusID = entity.StandStatusID;
            model.HoisterID = entity.HoisterID;
            model.HoisterUsageID = entity.HoisterUsageID;
            model.WireropeTypeID = entity.WireropeTypeID;
            model.GreenLight = entity.GreenLight;
            model.BlueLight = entity.BlueLight;
            model.YellowLight = entity.YellowLight;
            model.OrangeLight = entity.OrangeLight;

            return model;
        }
        #endregion

        #region 写数据
        /// <summary>
        /// 写数据，从Model对象转换成Entity对象
        /// </summary>
        /// <param name="model">ViewModel对象</param>
        /// <returns></returns>
        public override StandStatusDetail Model2Entity(StandStatusDetailModel model)
        {
            StandStatusDetail entity = new StandStatusDetail();

            entity.StandStatusDetailID = model.StandStatusDetailID;
            entity.GroupInfoID = model.GroupInfoID;
            entity.StandStatusID = model.StandStatusID;
            entity.HoisterID = model.HoisterID;
            entity.HoisterUsageID = model.HoisterUsageID;
            entity.WireropeTypeID = model.WireropeTypeID;
            entity.GreenLight = model.GreenLight;
            entity.BlueLight = model.BlueLight;
            entity.YellowLight = model.YellowLight;
            entity.OrangeLight = model.OrangeLight;

            return entity;
        }
        #endregion

        #region 搜索条件转换
        /// <summary>
        /// 搜索条件转换，从FilterModel对象转换成Where对象
        /// </summary>
        /// <param name="filterModel">FilterModel对象</param>
        /// <returns></returns>
        public override Expressionable<StandStatusDetail> FilterModel2Where(StandStatusDetailFilterModel filterModel)
        {
            var where = base.FilterModel2Where(filterModel);

            //编号
            if (filterModel._StandStatusDetailID.HasValue)
            {
                where = where.And(x => x.StandStatusDetailID == filterModel._StandStatusDetailID.Value);
            }
            if (filterModel._StandStatusDetailIDs.IsNotEmpty() && filterModel._StandStatusDetailIDs.Count > 0)
            {
                where = where.And(x => filterModel._StandStatusDetailIDs.Contains(x.StandStatusDetailID));
            }
            if (filterModel._NotStandStatusDetailIDs.IsNotEmpty() && filterModel._NotStandStatusDetailIDs.Count > 0)
            {
                where = where.And(x => !filterModel._NotStandStatusDetailIDs.Contains(x.StandStatusDetailID));
            }

            //集团
            if (filterModel._GroupInfoID.HasValue)
            {
                where = where.And(x => x.GroupInfoID == filterModel._GroupInfoID.Value);
            }
            if (filterModel._GroupInfoIDs.IsNotEmpty() && filterModel._GroupInfoIDs.Count > 0)
            {
                where = where.And(x => filterModel._GroupInfoIDs.Contains(x.GroupInfoID));
            }
            if (filterModel._NotGroupInfoIDs.IsNotEmpty() && filterModel._NotGroupInfoIDs.Count > 0)
            {
                where = where.And(x => !filterModel._NotGroupInfoIDs.Contains(x.GroupInfoID));
            }

            //状态标准
            if (filterModel._StandStatusID.HasValue)
            {
                where = where.And(x => x.StandStatusID == filterModel._StandStatusID.Value);
            }
            if (filterModel._StandStatusIDs.IsNotEmpty() && filterModel._StandStatusIDs.Count > 0)
            {
                where = where.And(x => filterModel._StandStatusIDs.Contains(x.StandStatusID));
            }
            if (filterModel._NotStandStatusIDs.IsNotEmpty() && filterModel._NotStandStatusIDs.Count > 0)
            {
                where = where.And(x => !filterModel._NotStandStatusIDs.Contains(x.StandStatusID));
            }

            //提升机类型
            if (filterModel._HoisterID.HasValue)
            {
                where = where.And(x => x.HoisterID == filterModel._HoisterID.Value);
            }
            if (filterModel._HoisterIDs.IsNotEmpty() && filterModel._HoisterIDs.Count > 0)
            {
                where = where.And(x => filterModel._HoisterIDs.Contains(x.HoisterID));
            }
            if (filterModel._NotHoisterIDs.IsNotEmpty() && filterModel._NotHoisterIDs.Count > 0)
            {
                where = where.And(x => !filterModel._NotHoisterIDs.Contains(x.HoisterID));
            }

            //提升用途
            if (filterModel._HoisterUsageID.HasValue)
            {
                where = where.And(x => x.HoisterUsageID == filterModel._HoisterUsageID.Value);
            }
            if (filterModel._HoisterUsageIDs.IsNotEmpty() && filterModel._HoisterUsageIDs.Count > 0)
            {
                where = where.And(x => filterModel._HoisterUsageIDs.Contains(x.HoisterUsageID));
            }
            if (filterModel._NotHoisterUsageIDs.IsNotEmpty() && filterModel._NotHoisterUsageIDs.Count > 0)
            {
                where = where.And(x => !filterModel._NotHoisterUsageIDs.Contains(x.HoisterUsageID));
            }

            //钢丝绳类型
            if (filterModel._WireropeTypeID.HasValue)
            {
                where = where.And(x => x.WireropeTypeID == filterModel._WireropeTypeID.Value);
            }
            if (filterModel._WireropeTypeIDs.IsNotEmpty() && filterModel._WireropeTypeIDs.Count > 0)
            {
                where = where.And(x => filterModel._WireropeTypeIDs.Contains(x.WireropeTypeID));
            }
            if (filterModel._NotWireropeTypeIDs.IsNotEmpty() && filterModel._NotWireropeTypeIDs.Count > 0)
            {
                where = where.And(x => !filterModel._NotWireropeTypeIDs.Contains(x.WireropeTypeID));
            }

            return where;
        }
        #endregion
    }
}

